/*****************/
function stopBubble(e) {
    // 如果传入了事件对象，那么就是非ie浏览器
    if (e && e.stopPropagation) {
        //因此它支持W3C的stopPropagation()方法
        e.stopPropagation();
    } else {
        //否则我们使用ie的方法来取消事件冒泡
        window.event.cancelBubble = true;
    }
}

var tap = "ontouchstart" in document ? "touchend" : "click";
var winWt = parseInt($(window).width()),
    winHt = parseInt($(window).height());

//实现滚动条无法滚动
var winHadntScroll = function(e) {
    e.preventDefault();
};

/***禁止滑动***/
function scrollStop() {
    var h = $(window).height();
    document.body.style.overflow = "hidden";
    document.addEventListener("touchmove", winHadntScroll, { passive: false }); //禁止页面滑动
}

/***取消滑动限制***/
function scrollMove() {
    document.body.style.overflow = ""; //出现滚动条
    document.removeEventListener("touchmove", winHadntScroll, { passive: false });
}

/// 锚点跳转
function anchorMove(id, fn) {
    var $obj = $(id),
        moveFun = fn;
    var oh = $obj.offset().top - parseInt($(".header").outerHeight());
    $("html,body").animate({
            scrollTop: oh,
        },
        300,
        function() {
            if (moveFun) moveFun();
        }
    );
}

/// 竖向滚动条
if ($(".scrollbox").length > 0) {
    $(".scrollbox").mCustomScrollbar({
        scrollInertia: 1000,
        advanced: {
            updateOnContentResize: true,
        },
    });
}
/// 横向滚动条
if ($(".scrollbox2").length > 0) {
    $(".scrollbox2").mCustomScrollbar({
        axis: "x",
        mouseWheel: true,
        advanced: {
            updateOnContentResize: true,
        },
    });
}

// 页面滚动wow.js再ie9以上引用
var wow = new WOW({
    boxClass: "wow",
    animateClass: "animated",
    offset: 100,
    mobile: true,
    live: true,
});
if (!/msie [6|7|8|9]/i.test(navigator.userAgent)) {
    wow.init();
}

// 模态框
$(".modal").on("shown.bs.modal", function() {
    $("body").addClass("modal-open");
});
$(".modal").on("hidden.bs.modal", function() {
    if ($(this).find("video").length) {
        var videoId = $(this).find(".video-js").attr("id");
        var myplayer = videojs(videoId);
        myplayer.pause();
        myplayer.currentTime(0);
    }
});
$(".modal-close")
    .off(tap)
    .on(tap, function() {
        var $modal = $(this).parents(".modal");
        $modal.modal("hide");
    });

// 判断设备
var os = (function() {
    var ua = navigator.userAgent,
        isWindowsPhone = /(?:Windows Phone)/.test(ua),
        isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,
        isAndroid = /(?:Android)/.test(ua),
        isIOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
        isFireFox = /(?:Firefox)/.test(ua),
        isChrome = /(?:Chrome|CriOS)/.test(ua),
        isTablet =
        /(?:iPad|PlayBook)/.test(ua) ||
        (isAndroid && !/(?:Mobile)/.test(ua)) ||
        (isFireFox && /(?:Tablet)/.test(ua)),
        isPhone = /(?:iPhone)/.test(ua) && !isTablet,
        isPc = !isPhone && !isAndroid && !isSymbian;
    return {
        isTablet: isTablet,
        isPhone: isPhone,
        isAndroid: isAndroid,
        isIOS: isIOS,
        isPc: isPc,
    };
})();

// 判断是否微信
function is_weixin() {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == "micromessenger") {
        return true;
    } else {
        return false;
    }
}

if (!os.isPc) {
    $("body").addClass("is-iphone");
} else {
    $("body").addClass("is-pc");
}
if (os.isAndroid) {
    $("body").addClass("is-android");
}
if (os.isIOS) {
    $("body").addClass("is-ios");
}

if (is_weixin()) {
    $("body").addClass("is-wx");
} else {
    $("body").addClass("not-wx");
}

// 单选框
$(".check-list label").on(tap, function() {
    $(this)
        .parent("li")
        .addClass("is-checked")
        .siblings()
        .removeClass("is-checked");
});

// 视频
$(".btn-open_video").on(tap, function() {
    $(".modal-video").modal("show");
});

$('[data-toggle="tab"]').on(tap, function() {
    var id = $(this).attr("href"),
        $lis = $(this).parent("li");
    $(this).tab("show");
    $lis.addClass("active").siblings().removeClass("active");
});

/******************************/


// PC端导航
$(".head-navlist > li").on("mouseenter", function() {
        $(this)
            .addClass("active")
            .find(".subnav-box")
            .stop(true, true)
            .slideDown(300)
            .end()
            .siblings("li")
            .removeClass("active")
            .find(".subnav-box")
            .hide();
        // $('.header .had-subnav.activeD::after').hide()
        $(".head-navlist .navlv1").removeClass("hab-subnav activeX");
        if ($(this).hasClass("had-subnav")) $(".header").addClass("open-subnav1");
    })
    .on("mouseleave", function() {
        $(this).removeClass("active").find(".subnav-box").hide();
        $(".header").removeClass("open-subnav");
        $(".head-navlist > li.current").addClass("active");
        $(".head-navlist .activeW").addClass("activeX");
        // $(this).find(".activeW").addClass("activeX");
    });

// 鼠标经过页头事件





// 回到顶部
$('.backtop').hide();
$(window).scroll(function() {
    if ($(this).scrollTop() > 100) {
        $('.backtop').fadeIn();
    } else {
        $('.backtop').fadeOut();
    }
});
$('.backtop').on('click', function() {
    $('html,body').animate({
        'scrollTop': '0'
    })
})

// 底部技术支持
if ($('.foot-jszc_swip').length) {
    var footJsSwip = new Swiper('.foot-jszc_swip', {
        direction: 'vertical',
        autoplay: {
            delay: 1000,
            disableOnInteraction: false,
        },
        loop: true,
        observer: true,
        observeParents: true,
    });
}

// $(".header").on("mouseover", function() {
//     $('body').addClass('head-white')
// })
// $(".header").on("mouseleave", function() {
//     $('body').removeClass('head-white')
// })

// 导航
$(window).scroll(function() {
        if ($(window).scrollTop() > 0) {
            $('body').addClass('head-white');
            $(".header").on("mouseleave", function() {
                $('body').addClass('head-white')
            })
        } else if ($(window).scrollTop() < 2) {
            $('body').removeClass('head-white');
            $(".header").on("mouseleave", function() {
                $('body').removeClass('head-white')
            })
        }
    })
    // if ($(window).scrollTop() == 0) {
    //     $('body').removeClass('head-white');
    // }
    // $('.nav-rightbox .searchbox').on('click', function() {
    //     $('.search-box').slideToggle();
    //     $('.bbg1').toggleClass('blackbgShow');
    //     if ($(window).scrollTop() == 0) {
    //         $('.header').toggleClass('head-white1');
    //     }
    // })

var windowWidth = $(window).width()
    // 搜索栏
$('.gg-search').on('click', function(e) {
    $('.search-box').slideToggle(300, 'linear');
    stopBubble(e)
        // e.stopPropagation();
        // e.preventDefault();
        // $('.ph-nav-box').removeClass('on')
        // $('.ph-nav-box').removeClass('on')
        // $('.head-menu_open').removeClass('on')
        // $('.head-menu_open').removeClass('open')
    $('body').toggleClass("head-white1")

    $('.ph-nav-box').removeClass('on')
    $('.ph-nav-box').removeClass('open')
    $('.head-menu_open').removeClass('on')
    $('.head-menu_open').removeClass('open')
    $('body').toggleClass("head-white-s")
    $('body').removeClass("head-white-c")
    $('body').removeClass("open")
        // $('body').css('overflow', 'inherit')
})

// $('.gg-search1').on('click', function(e) {
//     $('.search-box').slideToggle(300, 'linear');
//     e.stopPropagation();
//     e.preventDefault();
//     $('.ph-nav-box').removeClass('on')
//     $('.ph-nav-box').removeClass('on')
//     $('.head-menu_open').removeClass('on')
//     $('.head-menu_open').removeClass('open')
//     $('body').toggleClass("head-white-s")
//     $('body').removeClass("head-white-c")
// })


// $('.head-menu_open').on('click', function() {
//     $('body').toggleClass("head-white1")
//     if ($('body').find('.head-white1')) {
//         $('body').addClass("head-white1")
//     }
// })

// 搜索框冒泡
$(document).on('click', function(e) {
    $('.search-box').slideUp(300, 'linear');
    $('body').removeClass("head-white1")
    $('body').removeClass("head-white-s")
})
$('.search-box .global-inner').on('click', function(e) {
    e.stopPropagation();
    e.preventDefault();
})


// 移动端导航
$(".head-menu_open").on('click', function() {
    // $('body').toggleClass("head-white1")
    $('body').toggleClass("open")
    $(this).toggleClass("open")

    $(".ph-nav-box").toggleClass("on");
    // if ($(this).hasClass("open")) {
    //     scrollStop();
    // } else {
    //     scrollMove();
    // }
    if ($('body').hasClass('head-white1')) {
        $('body').addClass('head-white1')
    } else {
        $('body').removeClass('head-white1')
    }
    // $('body').toggleClass("head-white1")
    $('body').toggleClass('head-white-c')
    $('body').removeClass('head-white-s')
});

$('.headItem').click(function() {
    $(this).find('.headB').stop(true).slideToggle(200)
})
$(".ph-nav-box .lvbox").each(function() {
    $(this).siblings(".lv").find("em").show();
});

$(".lv1 em").on('click', function() {
    $(this).parents(".lv1").toggleClass("on").end()
        .parents(".lv1").siblings(".lv2box").stop(true, true).slideToggle(300).end()
        .parent("li").siblings().find(".lvbox").slideUp(300).siblings(".lv").removeClass("on");
});
$(".lv2 em").on('click', function() {
    $(this).parents(".lv2").toggleClass("on").end()
        .parents(".lv2").siblings(".lv3box").stop(true, true).slideToggle(300).end()
        .parents(".item").siblings().find(".lvbox").removeClass("on").slideUp(300).siblings(".lv").removeClass("on");
});
$(".lv3 em").on('click', function() {
    $(this).parents(".lv3").toggleClass("on").end()
        .parents(".lv3").siblings(".lv4box").stop(true, true).slideToggle(300).end()
        .parents(".item").siblings().find(".lvbox").slideUp(300).siblings(".lv").removeClass("on");
});


/*** 公共 ****/


// 公共样式
// 添加wow
$(window).on("load", function() {
    // 银行卡业务
    if ($(".gscet-13").length) {
        $(".gscet-13").addClass("animated fadeInUp2");
        $(".bank5-swiper .image").addClass("wow fadeInUp2");
        $(".bank5-swiper .item-hd").addClass("wow fadeInUp2");
    }
    // 首页
    if ($(".home-sect1").length) {
        $(".home-sect1").addClass("wow fadeInUp2");
    }

    if (wow && !/msie [6|7|8|9]/i.test(navigator.userAgent)) {
        wow.init();
    }
});

// PC端频道页banner轮播
var publicBanner = new Swiper(".public-banner", {
    speed: 500,
    watchOverflow: true,
    slidesPerView: 1,
    disableOnInteraction: false,
    autoplay: {
        delay: 5000,
        stopOnLastSlide: false,
        disableOnInteraction: true,
    },
    observeParents: true,
    observer: true,

    navigation: {
        nextEl: ".home-btn-next",
        prevEl: ".home-btn-prev",
    },
    pagination: {
        el: ".home-btn",
        clickable: true,
    },
});

if (publicBanner.slides.length <= 1) {
    $(".public-banner-btn").hide();
    $(".public-banner-btn-next").hide();
    $(".public-banner-btn-prev").hide();
    $(".public-banner").addClass("swiper-no-swiping");
}

// 集团要闻文字
var channel2Swiper = new Swiper(".channel1-swiper2", {
    // loop: true,
    speed: 500,
    watchOverflow: true,
    // effect: 'fade',
    // freeMode: true,

    watchSlidesProgress: true,
    autoplay: {
        delay: 5000,
        stopOnLastSlide: false,
        disableOnInteraction: true,
    },
    breakpoints: {
        0: {
            slidesPerView: 1,
            spaceBetween: 0,
            pagination: {
                el: ".channel1-btn2",
            },
        },
        992: {
            spaceBetween: 40,
            pagination: {
                el: ".channel1-btn2",
                clickable: true,
                type: 'fraction',
            },
        },
    },
    observeParents: true,
    observer: true,

    navigation: {
        nextEl: ".channel1-btn2-next",
        prevEl: ".channel1-btn2-prev",
    },
    thumbs: {
        swiper: channel1Swiper,
    },
    controller: {
        control: channel1Swiper
    }
});

if (channel2Swiper.slides.length <= 1) {
    $(".channel1-btn2").hide();
    $(".channel1-btn2-next").hide();
    $(".channel1-btn2-prev").hide();
    $(".channel1-swiper2").addClass("swiper-no-swiping");
}


// 集团要闻
var channel1Swiper = new Swiper(".channel1-swiper1", {
    // loop: true,
    effect: 'fade',
    speed: 500,
    watchOverflow: true,
    spaceBetween: 0,

    autoplay: {
        delay: 5000,
        stopOnLastSlide: false,
        disableOnInteraction: true,
    },
    breakpoints: {
        0: {
            slidesPerView: 1,
            // pagination: {
            //     el: ".channel1-btn",
            //     clickable: true,
            //     type: 'bullets',
            // },
        },
        992: {
            pagination: {
                el: ".channel1-btn",
                clickable: true,
                type: 'fraction',
            },
        },
    },
    observeParents: true,
    observer: true,

    navigation: {
        nextEl: ".channel1-btn-next",
        prevEl: ".channel1-btn-prev",
    },
    // thumbs: {
    //     swiper: channel2Swiper,
    // },
    controller: {
        control: channel2Swiper
    }
});

if (channel1Swiper.slides.length <= 1) {
    $(".channel1-btn").hide();
    $(".channel1-btn-next").hide();
    $(".channel1-btn-prev").hide();
    $(".channel1-swiper1").addClass("swiper-no-swiping");
}


// swiper相互控制
channel1Swiper.controller.control = channel2Swiper
channel2Swiper.controller.control = channel1Swiper

// 频道页
// if (windowWidth < 992) {
//     $('.p-channel .main-box').removeClass('global-inner1')
// } else if (windowWidth > 992) {
//     $('.p-channel .main-box').addClass('global-inner1')
// }

// PC端内页banner轮播
var insideBanner = new Swiper(".inside-banner", {
    observeParents: true,
    observer: true,
    speed: 500,
    watchOverflow: true,
    slidesPerView: 1,
    disableOnInteraction: false,
    autoplay: {
        delay: 5000,
        stopOnLastSlide: false,
        disableOnInteraction: true,
    },
    observer: true,
    observeParents: true,
    navigation: {
        nextEl: ".inside-btn-next",
        prevEl: ".inside-btn-prev",
    },
    pagination: {
        el: ".inside-btn",
        clickable: true,
    },
});

if (publicBanner.slides.length <= 1) {
    $(".inside-banner-btn").hide();
    $(".inside-banner-btn-next").hide();
    $(".inside-banner-btn-prev").hide();
    $(".inside-banner").addClass("swiper-no-swiping");
}


// 返回列表固定定位
// $(document).scroll(function() {
//     var juanHeight = $('.p-editor .main-box').offset().top
//         // console.log('juan', juanHeight)
//     var headerHeight = $('.header').offset().top
//         // console.log('头部', headerHeight)

//     if (headerHeight >= juanHeight) {
//         $('body').addClass('positionFixed')
//     } else {
//         $('body').removeClass('positionFixed')
//     }
// })


//  城发第二批页面 2022.09.15 开始
// 新面包屑手机端

if ($(".crumbs-new .box-mob .item-list").length) {
    $('.crumbs-new .box-mob .icon').on(tap, function(e) {
        $('body').toggleClass('mobCrumbs')
        $('.crumbs-new .box-mob .item-list').stop(true).slideToggle()
        e.stopPropagation();
    })

    $(document).on(tap, function() {
        $('.crumbs-new .box-mob .item-list').slideUp()
        $('body').removeClass('mobCrumbs')
    });
}

// ppp板块
var publicChannel3 = new Swiper(".p-pppswiper .public-channel3-swiper", {
    observeParents: true,
    observer: true,
    // cssMode: true,
    breakpoints: {
        340: {
            slidesPerView: 1,
            spaceBetween: 20,
        },
        992: {
            slidesPerView: 3,
            spaceBetween: 20,
        },
    },
    navigation: {
        nextEl: ".swiper-button-next",
        prevEl: ".swiper-button-prev",
    },
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },
    // mousewheel: true,
    // keyboard: true,
});

if (windowWidth > 992) {
    if (publicChannel3.slides.length <= 3) {
        $(".p-pppswiper .public-channel3-swiper-next").hide();
        $(".p-pppswiper .public-channel3-swiper-prev").hide();
        $(".p-pppswiper .public-channel3-swiper-btn").hide();
        $(".p-pppswiper .public-channel3-swiper").addClass("swiper-no-swiping");
    }
} else if (windowWidth < 992) {
    if (publicChannel3.slides.length <= 1) {
        $(".p-pppswiper .public-channel3-swiper-next").hide();
        $(".p-pppswiper .public-channel3-swiper-prev").hide();
        $(".p-pppswiper .public-channel3-swiper-btn").hide();
        $(".p-pppswiper .public-channel3-swiper").addClass("swiper-no-swiping");
    }
}

// 类金融模块-业务介绍
var publicChannel3s = new Swiper(".p-bankdel .public-channel3-swiper", {
    observeParents: true,
    observer: true,
    // cssMode: true,
    breakpoints: {
        340: {
            slidesPerView: 1,
            spaceBetween: 20,
        },
        992: {
            slidesPerView: 3,
            spaceBetween: 20,
        },
    },
    navigation: {
        nextEl: ".swiper-button-next",
        prevEl: ".swiper-button-prev",
    },
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },
    // mousewheel: true,
    // keyboard: true,
});
if (windowWidth > 992) {
    if (publicChannel3s.slides.length <= 3) {
        $(".p-bankdel .public-channel3s-swiper-next").hide();
        $(".p-bankdel .public-channel3s-swiper-prev").hide();
        $(".p-bankdel .public-channel3s-swiper-btn").hide();
        $(".p-bankdel .public-channel3s-swiper").addClass("swiper-no-swiping");
    }
} else if (windowWidth < 992) {
    if (publicChannel3s.slides.length <= 1) {
        $(".p-bankdel .public-channel3s-swiper-next").hide();
        $(".p-bankdel .public-channel3s-swiper-prev").hide();
        $(".p-bankdel .public-channel3s-swiper-btn").hide();
        $(".p-bankdel .public-channel3s-swiper").addClass("swiper-no-swiping");
    }
}

// 建设管理板块
var publicChannel4 = new Swiper(".p-management .public-channel4-swiper", {
    observeParents: true,
    observer: true,
    breakpoints: {
        340: {
            slidesPerView: 1,
            spaceBetween: 20,
        },
        992: {
            slidesPerView: 2,
            spaceBetween: 12,
        },
    },
    navigation: {
        nextEl: ".public-channel4-swiper-next",
        prevEl: ".public-channel4-swiper-prev",
    },
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },
    // mousewheel: true,
    // keyboard: true,
});
if (windowWidth > 992) {
    if (publicChannel4.slides.length <= 1) {
        $(".p-management .public-channel4-swiper-next").hide();
        $(".p-management .public-channel4-swiper-prev").hide();
        $(".p-management .public-channel4-swiper-btn").hide();
        $(".p-management .public-channel4-swiper").addClass("swiper-no-swiping");
    }
} else if (windowWidth < 992) {
    if (publicChannel4.slides.length <= 1) {
        $(".p-management .public-channel4-swiper-next").hide();
        $(".p-management .public-channel4-swiper-prev").hide();
        $(".p-management .public-channel4-swiper-btn").hide();
        $(".p-management .public-channel4-swiper").addClass("swiper-no-swiping");
    }
}

// 资产开发板块
var publicChannel4s = new Swiper(".p-property .public-channel4-swiper", {
    observeParents: true,
    observer: true,
    breakpoints: {
        340: {
            slidesPerView: 1,
            spaceBetween: 20,
        },
        992: {
            slidesPerView: 2,
            spaceBetween: 12,
        },
    },
    navigation: {
        nextEl: ".public-channel4-swiper-next",
        prevEl: ".public-channel4-swiper-prev",
    },
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },
    // mousewheel: true,
    // keyboard: true,
});
if (windowWidth > 992) {
    if (publicChannel4s.slides.length <= 2) {
        $(".p-property .public-channel4-swiper-next").hide();
        $(".p-property .public-channel4-swiper-prev").hide();
        $(".p-property .public-channel4-swiper-btn").hide();
        $(".p-property .public-channel4-swiper").addClass("swiper-no-swiping");
    }
} else if (windowWidth < 992) {
    if (publicChannel4s.slides.length <= 1) {
        $(".p-property .public-channel4-swiper-next").hide();
        $(".p-property .public-channel4-swiper-prev").hide();
        $(".p-property .public-channel4-swiper-btn").hide();
        $(".p-property .public-channel4-swiper").addClass("swiper-no-swiping");
    }
}

// 类金融业务介绍
var channel8Swiper = new Swiper(".channel8-swiper", {
    observeParents: true,
    observer: true,

    breakpoints: {
        340: {
            slidesPerView: 1,
            spaceBetween: 0,
        },
        992: {
            width: 'auto',
            slidesPerView: 2,
            spaceBetween: 60,
        },
    },
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },
});

if (windowWidth > 992) {
    if (channel8Swiper.slides.length <= 4) {
        $(".channel8-swiper").addClass("swiper-no-swiping");
    }
}
// else if (windowWidth < 992) {
//     if (channel8Swiper.slides.length <= 1) {
//         $(".channel8-swiper-btn").hide();
//         $(".channel8-swiper").addClass("swiper-no-swiping");
//     }
// }

// 业务板块
var ywbkSwiper = new Swiper(".ywbk-swiper", {
    grabCursor: true,
    effect: "creative",
    creativeEffect: {
        prev: {
            shadow: true,
            translate: ["-120%", 0, -500],
        },
        next: {
            shadow: true,
            translate: ["120%", 0, -500],
        },
    },
    // grabCursor: true,
    // effect: 'creative',
    // creativeEffect: {
    //     prev: {
    //         shadow: true,
    //         translate: ["-120%", 0, -500],
    //     },
    //     next: {
    //         shadow: true,
    //         translate: ["120%", 0, -500],
    //     },
    // },
    observeParents: true,
    observer: true,
    slidesPerView: 1,
    spaceBetween: 20,
    navigation: {
        nextEl: ".ywbk-swiper-next",
        prevEl: ".ywbk-swiper-prev",
    },
});
if (ywbkSwiper.slides.length <= 1) {
    $(".ywbk-swiper-next").hide();
    $(".ywbk-swiper-prev").hide();
    $(".ywbk-swiper").addClass("swiper-no-swiping");
}

// 通讯智慧板块-业务介绍
var channel12Swiper = new Swiper(".channel12-swiper", {
    observeParents: true,
    observer: true,
    spaceBetween: 30,
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },

});

if (channel12Swiper.slides.length <= 1) {
    $(".channel12-swiper-btn").hide();
    $(".channel12-swiper").addClass("swiper-no-swiping");
}

// 管廊展示
var channel17Swiper = new Swiper(".public-channel17-swiper", {
    observeParents: true,
    observer: true,
    spaceBetween: 30,
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },
});

if (channel17Swiper.slides.length <= 1) {
    $(".public-channel17-swiper-btn").hide();
    $(".public-channel17-swiper").addClass("swiper-no-swiping");
}

var channel17PcSwiper = new Swiper(".public-channel17-pc-swiper", {
    observeParents: true,
    observer: true,
    slidesPerView: 1,
    spaceBetween: 30,
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },
    navigation: {
        nextEl: ".public-channel17-pc-swiper-next",
        prevEl: ".public-channel17-pc-swiper-prev",
    },
});

if (channel17PcSwiper.slides.length <= 1) {
    $(".public-channel17-pc-swiper-next").hide();
    $(".public-channel17-pc-swiper-prev").hide();
    $(".public-channel17-pc-swiper").addClass("swiper-no-swiping");
}

// 管廊展示地图
var channel18Swiper = new Swiper(".channel18-swiper", {
    observeParents: true,
    observer: true,
    spaceBetween: 30,
    pagination: {
        el: ".swiper-pagination",
        clickable: true,
    },
});

if (channel18Swiper.slides.length <= 1) {
    $("channel18-swiper-btn").hide();
    $("channel18-swiper").addClass("swiper-no-swiping");
}

// 项目弹框
var popProjecSwiper = new Swiper(".p-new-channel .pop-projec-swiper", {
    observeParents: true,
    observer: true,
    slidesPerView: 1,
    spaceBetween: 20,
    // loop: true,
    grabCursor: true,
    effect: "creative",
    navigation: {
        nextEl: ".p-new-channel .pop-projec-swiper-next",
        prevEl: ".p-new-channel .pop-projec-swiper-prev",
    },
    pagination: {
        el: ".p-new-channel .pop-projec-banner-btn",
        clickable: true,
    },
});
if (popProjecSwiper.slides.length <= 1) {
    $(".p-new-channel .pop-projec-swiper-next").hide();
    $(".p-new-channel .pop-projec-swiper-prev").hide();
    $(".p-new-channel .pop-projec-banner-btn").hide();
    $(".p-new-channel .pop-projec-swiper").addClass("swiper-no-swiping");
}


// var ww1 = $(".p-company .pop-projec-swiper li")

// console.log(ww1.length);
// console.log(popPww1rojecSwiper1.slides.length);


// 清廉国企
if (windowWidth > 992) {
    $('.channel21 .lefts .list .item').on('click', function() {
        $(this).addClass('active').siblings().removeClass('active')

        $('.channel21 .rights .public-channel21-swiper').eq($(this).index()).css('display', 'block').animate({
            'opacity': '1'
        }).siblings().css({
            'opacity': '0',
            'display': 'none'
        })
        $('.channel21 .rights .blank').css('display', 'block')
        $('.channel21 .rights .blank').css('opacity', '1')
    })
}


// 清廉文化阵地
var channel21Swiper = new Swiper(".channel21-swiper", {
    observeParents: true,
    observer: true,
    slidesPerView: 1,
    spaceBetween: 20,
    loop: true,
    pagination: {
        el: ".channel21-swiper-pagination",
        clickable: true,
    },
    navigation: {
        nextEl: ".channel21-swiper-next",
        prevEl: ".channel21-swiper-prev",
    },
});
// console.log(channel21Swiper.slides.length)

var channel21Swiper2 = new Swiper(".channel21-swiper-2", {
    observeParents: true,
    observer: true,
    slidesPerView: 1,
    spaceBetween: 20,
    loop: true,
    pagination: {
        el: ".channel21-swiper-pagination-2",
        clickable: true,
    },
    navigation: {
        nextEl: ".channel21-swiper-next-2",
        prevEl: ".channel21-swiper-prev-2",
    },
});
// console.log(channel21Swiper2.slides.length)

var channel21Swiper3 = new Swiper(".channel21-swiper-3", {
    observeParents: true,
    observer: true,
    slidesPerView: 1,
    spaceBetween: 20,
    loop: true,
    pagination: {
        el: ".channel21-swiper-pagination-3",
        clickable: true,
    },
    navigation: {
        nextEl: ".channel21-swiper-next-3",
        prevEl: ".channel21-swiper-prev-3",
    },
    observer: true,
    observeParents: true,
});
// console.log(channel21Swiper2.slides.length)

var channel21Swiper4 = new Swiper(".channel21-swiper-4", {
    observeParents: true,
    observer: true,
    slidesPerView: 1,
    spaceBetween: 20,
    loop: true,
    pagination: {
        el: ".channel21-swiper-pagination-4",
        clickable: true,
    },
    navigation: {
        nextEl: ".channel21-swiper-next-4",
        prevEl: ".channel21-swiper-prev-4",
    },
    observer: true,
    observeParents: true,
});
// if (channel21Swiper.slides.length <= 1) {
//     $(".channel21-swiper-next").hide();
//     $(".channel21-swiper-prev").hide();
//     $(".channel21-swiper-pagination").hide();
//     $(".channel21-swiper").addClass("swiper-no-swiping");
// }
// console.log(channel21Swiper2.slides.length)
// if (channel21Swiper2.slides.length <= 1) {
//     $(".channel21-swiper-next-2").hide();
//     $(".channel21-swiper-prev-2").hide();
//     $(".channel21-swiper-pagination-2").hide();
//     $(".channel21-swiper-2").addClass("swiper-no-swiping");
// }
// if (channel21Swiper3.slides.length <= 1) {
//     $(".channel21-swiper-next-3").hide();
//     $(".channel21-swiper-prev-3").hide();
//     $(".channel21-swiper-pagination-3").hide();
//     $(".channel21-swiper-3").addClass("swiper-no-swiping");
// }

// if (channel21Swiper4.slides.length <= 1) {
//     $(".channel21-swiper-next-4").hide();
//     $(".channel21-swiper-prev-4").hide();
//     $(".channel21-swiper-pagination-4").hide();
//     $(".channel21-swiper-4").addClass("swiper-no-swiping");
// }
// this.channel21Swiper4.stopAutoplay();
// this.channel21Swiper4.startAutoplay();

var msqDel = $('.form-msqdel .form-group-cell label input').val()
    // console.log(msqDel);
    // if (msqDel) {
    //     var val = $('.form-msqdel .form-group-cell label input').val()
    //     $(val).attr('id', msqDel)
    // }


// var val = $('.form-msqdel .form-group-cell label input')
// $('.form-msqdel .form-group-cell label input').ready(function() {
//     // var msqDel1 = $('.form-msqdel .form-group-cell label input').val()
//     var msqDel1 = $(this).val()
//     console.log(msqDel1);
//     $(this).attr('id', msqDel1)
// })

// 看房详情1
var roomIntordSwiper2 = new Swiper(".roomintord-swiper2", {
    // loop: true,
    spaceBetween: 15,
    slidesPerView: 3,
    freeMode: true,
    watchSlidesProgress: true,
    observeParents: true,
    observer: true,
});
var roomIntordSwiper1 = new Swiper(".roomintord-swiper1", {
    loop: true,
    spaceBetween: 10,
    observeParents: true,
    observer: true,
    navigation: {
        nextEl: ".swiper-button-next",
        prevEl: ".swiper-button-prev",
    },
    thumbs: {
        swiper: roomIntordSwiper2,
    },
});

// 在线看房列表 弹窗swiper
var roomIntordSwiper4 = new Swiper(".roomintord-swiper4", {
    // loop: true,
    // noSwipingClass: 'stop-swiping',
    // cssMode: true,
    spaceBetween: 15,
    slidesPerView: 3,
    // freeMode: true,
    watchSlidesProgress: true,
    paginationClickable: true,
    observeParents: true,
    observer: true,
    thumbs: {
        swiper: roomIntordSwiper3,
    },
    controller: {
        control: roomIntordSwiper3
    },
});
// console.log(roomIntordSwiper4.slides.length, '111')
if (roomIntordSwiper4.slides.length <= 4) {
    // $(".channel21-swiper-next-4").hide();
    // $(".channel21-swiper-prev-4").hide();
    // $(".channel21-swiper-pagination-4").hide();
    // $(".roomintord-swiper4").addClass("swiper-no-swiping");
}
var roomIntordSwiper3 = new Swiper(".roomintord-swiper3", {
    // loop: true,
    spaceBetween: 10,
    navigation: {
        nextEl: ".roomintord-swiper3-next",
        prevEl: ".roomintord-swiper3-prev",
    },
    pagination: {
        el: ".roomintord-swiper3-pagination",
    },
    thumbs: {
        swiper: roomIntordSwiper4,
    },
    // controller: {
    //     control: roomIntordSwiper4,
    // },
    paginationClickable: true,
    observeParents: true,
    observer: true,
});
// roomIntordSwiper3.controller.control = roomIntordSwiper4
// roomIntordSwiper4.controller.control = roomIntordSwiper3



// 问题咨询
$('.channel31 .list .item').on('click', function() {
    $(this).find('.reply').slideToggle();
    $(this).siblings().find('.reply').slideUp();
    $(this).toggleClass('channel31-active').siblings().removeClass('channel31-active');
});

var glSwiper = new Swiper(".add-gl-swiper", {
    watchSlidesProgress: true,
    paginationClickable: true,
    observeParents: true,
    observer: true,
    spaceBetween: 40,

    navigation: {
        nextEl: ".add-gl-swiper-next",
        prevEl: ".add-gl-swiper-prev",
    },
    pagination: {
        el: ".add-gl-swiper-pagination",
    },
    cssMode: true,
    mousewheel: true,
    keyboard: true,
});


// 管廊详情页

// var pipeDelSwiper1 = new Swiper(".pipedel-swiper1", {
//     spaceBetween: 15,
//     // watchSlidesProgress: true,
//     // paginationClickable: true,
//     observeParents: true,
//     observer: true,
//     // thumbs: {
//     //     swiper: pipeDelSwiper2,
//     // },
//     controller: {
//         control: pipeDelSwiper2,
//     },
// });
// pipeDelSwiper1.controller.control = pipeDelSwiper2
// pipeDelSwiper2.controller.control = pipeDelSwiper1


var pipeDelSwiper2 = new Swiper(".pipedel-swiper2", {
    spaceBetween: 15,

    breakpoints: {
        340: {
            slidesPerView: 2,
            direction: "horizontal",
        },
        992: {
            slidesPerView: 3,
            direction: "vertical",
        },
    },
    navigation: {
        nextEl: ".pipedel-swiper2-next",
        prevEl: ".pipedel-swiper2-prev",
    },
    // thumbs: {
    //     swiper: pipeDelSwiper1,
    // },
    // controller: {
    //     control: pipeDelSwiper1,
    // },
    // paginationClickable: true,
    observeParents: true,
    observer: true,
});

$('.pipedel-swiper2').each(function() {
    if ($(this).find('.swiper-slide').length <= 3) {
        // $(this).find(".bgk").hide()
        // $(this).find(".bi").hide()
        $(this).addClass("swiper3")
    }


})

// pipeDelSwiper2.controller.control = pipeDelSwiper1
// pipeDelSwiper1.controller.control = pipeDelSwiper2

//swiper2控制swiper1，必须在swiper1初始化后

//swiper1控制swiper2，必须在swiper2初始化后


// 在线看房
var roomList = $(".channel24 .choose .premiseSelectItems .choose-list .choose-item").length
    // console.log(roomList);
if (windowWidth < 992) {
    if (roomList <= 2) {
        $(".channel24 .choose .premiseSelectItems").css('justify-content', 'inherit')
        $(".channel24 .choose .premiseSelectItems .name").css('width', '.75rem')
    }
}

if ($(".checkPremise-all").is(':checked')) {
    console.log('55')
}

$(function() {
    var $all = $('.checkPremise-all');
    var $item = $('.checkPremise');
    $all.click(function() {
        if ($(this).prop('checked')) {
            $item.prop('checked', true);
            $(this).next().text('取消全选');
        } else {
            $item.prop('checked', false);
            $(this).next().text('全选');
        }

    });

    $item.click(function() {
        var index = $item.index(this)
        if ($(this).prop('checked')) {
            var allTrue = true;
            $item.each(function(i) {
                if (index != i) {
                    if (!$(this).prop('checked')) {
                        allTrue = false;
                    }
                }
            });

            if (allTrue) {
                $all.prop('checked', true);
                $all.next().text('取消全选');
            }
        } else {
            $all.prop('checked', false);
            $all.next().text('全选');
        }
    })


})
$(function() {
    var $all = $('.checkUnit-all');
    var $item = $('.checkUnit');
    $all.click(function() {
        if ($(this).prop('checked')) {
            $item.prop('checked', true);
            $(this).next().text('取消全选');
        } else {
            $item.prop('checked', false);
            $(this).next().text('全选');
        }

    });

    $item.click(function() {
        var index = $item.index(this)
        if ($(this).prop('checked')) {
            var allTrue = true;

            $item.each(function(i) {
                if (index != i) {
                    if (!$(this).prop('checked')) {
                        allTrue = false;
                    }
                }
            });

            if (allTrue) {
                $all.prop('checked', true);
                $all.next().text('取消全选');
            }
        } else {
            $all.prop('checked', false);
            $all.next().text('全选');
        }
    })
})

// 管理
$('.channel27 .pipedel-swiper2 .swiper-slide').on('click', function() {
        // var smimg = $(this).find(".image").attr('src')
        // var bigimg = $(this).parents(".boxs").find(".pipedel-swiper1 .swiper-slide .imgs .image").attr('src', smimg)
        // var bigimg = smimg
        // console.log(smimg, 'smimg')
        // console.log(bigimg, 'bigimg')
        $(this).addClass('active').siblings().removeClass('active')
        $(this).parents(".boxs").find(".pipedel-swiper1 .swiper-slide").eq($(this).index()).css('display', 'block').animate({
            'opacity': '1',
            'display': 'block'
        }).siblings().css({
            'opacity': '0',
            'display': 'none'
        })
    })
    // 页脚
$(".footer .foot-t1 .other .brother").hover(function() {
    var i = $(this).index();
    $(".prod-top .item").eq(i).addClass("on").siblings().removeClass("on");
    $(".prod-bot .item").eq(i).addClass("on").siblings().removeClass("on");
});

if (windowWidth > 992) {
    $(".footer .foot-t1 .other .brother").hover(function() {
        // $(this).find(".links-con").stop(true, true).slideToggle(300);
        $(this).find(".hd-box").stop(true, true).slideToggle(300);
        $(this).toggleClass("xuanfan")
    });

}

if (windowWidth < 992) {
    $(".footer .foot-t1 .other .brother").on('click', function(e) {
        $(this).toggleClass("xuanfan")
        $(this).find(".hd-box").stop(true, true).slideToggle(300);
        stopBubble(e);
    });
    $("body").on('click', function() {
        $(".footer .brother").removeClass("xuanfan");
        $(".footer .hd-box").slideUp('300');

    });
}